package com.gs.synedocket.adapter;

import android.content.Context;
import android.widget.TextView;

import com.gs.synedocket.R;
import com.gs.synedocket.adapter.base.BaseAdapter;
import com.gs.synedocket.adapter.base.BaseViewHolder;
import com.gs.synedocket.db.dto.MenuDto;

import java.util.List;

public class MenuListAdapter extends BaseAdapter<MenuDto> {
    public MenuListAdapter(Context context, List<MenuDto> list, int layoutId) {
        super(context, list, layoutId);
    }

    @Override
    public void convert(BaseViewHolder holder, MenuDto item, int position) {
        TextView tv = holder.fd(R.id.tv_menu);
        tv.setText(item.getName());
        tv.setSelected(item.getSelect() != null && item.getSelect());
    }

    public void changeSelect(int position) {
        for (int i = 0; i < getItemCount(); i++) {
            list.get(i).setSelect(false);
        }
        list.get(position).setSelect(true);
        notifyDataSetChanged();
    }
}
